from core import models

from rest_flex_fields import FlexFieldsModelSerializer
from rest_framework import serializers

from .query import (
    FontCSSQuerySerializer
)


class UnicodeRangeSerializer(FlexFieldsModelSerializer):
    class Meta:
        model = models.UnicodeRange

        fields = '__all__'


class FontFileSerializer(FlexFieldsModelSerializer):
    format = serializers.ReadOnlyField()

    class Meta:
        model = models.FontFile

        fields = '__all__'

        expandable_fields = {
            'unicode_ranges': (
                UnicodeRangeSerializer,
                {
                    'omit': ('id',),
                    'many': True
                }
            )
        }


class FontSerializer(FlexFieldsModelSerializer):
    class Meta:
        model = models.Font

        fields = '__all__'

        expandable_fields = {
            'files': (FontFileSerializer, {'omit': ('id',), 'many': True})
        }
